
<?php //echo "<pre>"; print_r($info[2]); echo "</pre>";?>
<script>
    $(document).ready(function(){

        $('#all_access').click(function(){
     	   var checked_status = this.checked;
            $.each($('.access'),function(){
                   
         	   this.checked=checked_status;

                });

            });

        $('#all_add').click(function(){
     	   var checked_status = this.checked;
            $.each($('.add'),function(){
                   
         	   this.checked=checked_status;

                });

            });

        $('#all_edit').click(function(){
     	   var checked_status = this.checked;
            $.each($('.edit'),function(){
                   
         	   this.checked=checked_status;

                });

            });
    })


	 
	</script>

<div><?php echo validation_errors(); ?>

<form id="customForm" method="post"
	action="<?php echo site_url()?>/permission/add_permissions/">
<table id='myTable' name='myTable' class='tablesorter' border='0'
	cellspacing='1' cellpadding='0'>
	<thead>
		<tr>
			<th width="20px">#</th>
			<th><?php echo "mod name"?></th>

			<td><input type='checkbox' id='all_access' name='all_access' /><?php echo $permissions[1] ?></td>
<td><input type='checkbox' id='all_add'  name='all_add'  /><?php echo $permissions[2] ?></td>
<td><input type='checkbox' id='all_edit'  name='all_edit'  /><?php echo $permissions[3] ?></td>

		</tr>
		</thead>
		<tbody>
		<?php
			//echo count($info);
			$i = 0;
			foreach($info as $row => $value){
				
				echo "<tr>";
				echo "<td width='20px'>". ++$i ."</td>";
				echo "<td>". $value['name'] .'</td>';
				foreach ($permissions as $id=>$desc) {
					$checked="";
					if(!empty($pagePermissions[$groupID][$value['id']][$id])) $checked="checked";
				echo "<td><input type='checkbox' class='{$desc}'  name='{$desc}[$value[id]]' $checked /></td>";
				}
				echo "</tr>";
			}
		?>
		</table>
		
			<input type="hidden" id="groupID" name="groupID"  value="<?php if(!empty($groupID)) echo $groupID; ?>" />
			<input type="submit" id="submit" name="submit"  value="<?php echo lang('form_label_save')?>" />
		
	</form>
	</div>
	
